<?xml version="1.0" encoding="iso-8859-1"?>
<project name="YUI Compressor" default="build.jar" basedir=".">

    <target name="clean" depends="-load.properties">
        <delete dir="${build.dir}" quiet="true"/>
    </target>

    <target name="-load.properties">
        <property file="ant.properties"/>
    </target>

    <target name="-init" depends="-load.properties">
        <mkdir dir="${build.dir}"/>
    </target>

    <target name="build.classes" depends="-init">
        <mkdir dir="${build.dir}/classes"/>
        <javac srcdir="${src.dir}"
               destdir="${build.dir}/classes"
               includes="**/*.java"
               deprecation="off"
               debug="on"
	       target="1.5"
               source="1.5">
            <classpath>
                <pathelement location="${lib.dir}/jargs-1.0.jar"/>
                <pathelement location="${lib.dir}/rhino-1.6R7.jar"/>
            </classpath>
        </javac>
    </target>

    <target name="build.jar" depends="build.classes">
        <mkdir dir="${build.dir}/jar"/>
        <!-- The order is important here. Rhino MUST be unjarred first!
             (some of our own classes will override the Rhino classes) -->
        <unjar src="${lib.dir}/jargs-1.0.jar" dest="${build.dir}/jar"/>
        <unjar src="${lib.dir}/rhino-1.6R7.jar" dest="${build.dir}/jar"/>
        <copy todir="${build.dir}/jar">
            <fileset dir="${build.dir}/classes" includes="**/*.class"/>
        </copy>
        <jar destfile="${build.dir}/${jar.name}" basedir="${build.dir}/jar">
            <manifest>
                <attribute name="Main-Class" value="com.yahoo.platform.yui.compressor.Bootstrap"/>
            </manifest>
        </jar>
    </target>

    <target name="build.dist.package" depends="build.jar">
        <mkdir dir="${build.dir}/${dist.package.name}"/>
        <mkdir dir="${build.dir}/${dist.package.name}/build"/>
        <copy file="${build.dir}/${jar.name}" todir="${build.dir}/${dist.package.name}/build"/>
        <copy todir="${build.dir}/${dist.package.name}">
            <fileset dir=".">
                <include name="ant.properties"/>
                <include name="build.xml"/>
                <include name="doc/**/*"/>
                <include name="lib/**/*"/>
                <include name="src/**/*"/>
                <exclude name="**/CVS"/>
            </fileset>
        </copy>
        <zip destfile="${build.dir}/${dist.package.name}.zip"
             basedir="${build.dir}"
             includes="${dist.package.name}/**/*"/>
    </target>

</project>
